package com.csii.oauth.filter;

import com.csii.oauth.filter.exchange.IAuthExchange;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 将token 转换为
 *
 * @Auther: Ian
 */
public class TokenAuthenticationFilter extends OncePerRequestFilter {

	private IAuthExchange authExchange;
	public TokenAuthenticationFilter(IAuthExchange authExchange){
		this.authExchange=authExchange;
	}


	@Override
	protected void doFilterInternal(HttpServletRequest request,
									HttpServletResponse response,
									FilterChain filterChain) throws ServletException, IOException {
		authExchange.exchange(request,response);
		// 放行请求
		filterChain.doFilter(request, response);
	}


}
